import 'dart:typed_data';

import 'package:usbflutter/usb/UsbPackage.dart';

class DeviceStatus {
  DeviceStatus._();

  static const int NONE = 0;
  static const int CONNECTED = 1;
  static const int SIDCONNECTED = 2;
}

class IDeviceHandler {
  int status = DeviceStatus.NONE;

  /// 波特率
  int baudRate = 192000;

  /// 历史数据列表
  List<Uint8List> list = [];

  dynamic currentValue;

  void onNewData(UsbPackage package) {
    if (package.event==UsbPackage.NEW_DATA) {
      parse(package);
      return;
    }
    if (package.event == UsbPackage.DISCONNECT) {
      status = DeviceStatus.SIDCONNECTED;
    }
  }

  void parse(UsbPackage package) {

  }

  @override
  String toString() {
    return '$currentValue';
  }
}
